import 'package:banyou_app/app/config/colors.dart';

import 'package:banyou_app/app/widget/login_input.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class YouWidget extends StatefulWidget {
  const YouWidget({Key? key}) : super(key: key);

  @override
  State<YouWidget> createState() => _YouWidgetState();
}

class _YouWidgetState extends State<YouWidget> {
  String mdd = '';
  String cfsj = '';
  String cxfs = '';

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: ColorConfig.white,
        borderRadius: BorderRadius.vertical(top: Radius.circular(34)),
      ),
      width: 1.sw,
      height: 500,
      padding: EdgeInsets.symmetric(horizontal: 28),
      child: SingleChildScrollView(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(height: 70),
            Text('目的地',
                style:
                    TextStyle(color: ColorConfig.text_label, fontSize: 16.sp)),
            SizedBox(height: 20),
            Container(
                decoration: BoxDecoration(
                    color: ColorConfig.white,
                    borderRadius: BorderRadius.all(Radius.circular(30)),
                    border: Border.all(color: Color(0x1A131313))),
                alignment: Alignment.center,
                padding: EdgeInsets.symmetric(
                  horizontal: 15,
                ),
                child: LoginInput(
                  title: "",
                  hint: "请输入目的地",
                  keyBoardType: TextInputType.text,
                  onChanged: (text) {
                    mdd = text;
                    // controller.checkInput();
                  },
                )),
            SizedBox(height: 20),
            Text('出发时间',
                style:
                    TextStyle(color: ColorConfig.text_label, fontSize: 16.sp)),
            SizedBox(height: 20),
            Container(
                decoration: BoxDecoration(
                    color: ColorConfig.white,
                    borderRadius: BorderRadius.all(Radius.circular(30)),
                    border: Border.all(color: Color(0x1A131313))),
                alignment: Alignment.center,
                padding: EdgeInsets.symmetric(
                  horizontal: 15,
                ),
                child: LoginInput(
                  title: "",
                  hint: "请输入出发时间",
                  keyBoardType: TextInputType.text,
                  onChanged: (text) {
                    cfsj = text;
                    // controller.checkInput();
                  },
                )),
            SizedBox(height: 20),
            Text('出行方式',
                style:
                    TextStyle(color: ColorConfig.text_label, fontSize: 18.sp)),
            SizedBox(height: 20),
            Container(
                decoration: BoxDecoration(
                    color: ColorConfig.white,
                    borderRadius: BorderRadius.all(Radius.circular(30)),
                    border: Border.all(color: Color(0x1A131313))),
                alignment: Alignment.center,
                padding: EdgeInsets.symmetric(
                  horizontal: 15,
                ),
                child: LoginInput(
                  title: "",
                  hint: "请输入出行方式",
                  keyBoardType: TextInputType.text,
                  onChanged: (text) {
                    cxfs = text;
                    // controller.checkInput();
                  },
                )),
            SizedBox(height: 42),
            Row(
              children: [
                Expanded(
                  child: InkWell(
                    child: Container(
                      width: 211.w,
                      height: 45,
                      decoration: BoxDecoration(
                        border: Border.all(color: ColorConfig.diver_color),
                        borderRadius: BorderRadius.circular(20),
                      ),
                      child: Center(
                        child: Text(
                          "取消",
                          style: TextStyle(
                              color: ColorConfig.body1_txt_color,
                              fontSize: 16,
                              fontWeight: FontWeight.w500),
                        ),
                      ),
                    ),
                    onTap: () {
                      Get.back();
                    },
                  ),
                ),
                SizedBox(width: 10),
                Expanded(
                  child: InkWell(
                    child: Container(
                      width: 211.w,
                      height: 45,
                      decoration: BoxDecoration(
                        gradient: LinearGradient(
                            begin: Alignment.centerLeft,
                            end: Alignment.centerRight,
                            colors: [
                              Color(0xFFF52EC5),
                              Color(0xFFFF8A33),
                            ]),
                        borderRadius: BorderRadius.circular(20),
                      ),
                      child: Center(
                        child: Text(
                          "确定",
                          style: TextStyle(
                              color: ColorConfig.white,
                              fontSize: 16,
                              fontWeight: FontWeight.w500),
                        ),
                      ),
                    ),
                    onTap: () {
                      if (mdd.isEmpty || cxfs.isEmpty || cfsj.isEmpty) {
                        EasyLoading.showToast('请填写出行信息');
                      } else {
                        EasyLoading.show();
                        Future.delayed(Duration(seconds: 2), () {
                          EasyLoading.dismiss();
                          EasyLoading.showToast('申请成功');
                          Get.back(result: 1);
                        });
                      }
                    },
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
